package logic

import (
	"github.com/gin-gonic/gin"
	"github.com/vueadmin/app/admin/internal/dto"
	"github.com/vueadmin/app/admin/internal/model"
	"github.com/vueadmin/app/admin/internal/service"
	"github.com/vueadmin/app/admin/internal/svc"
	"github.com/vueadmin/app/admin/internal/vo"
)

type adminuserLogic struct {
	ctx    *gin.Context
	svcCtx *svc.ServiceContext
}

func NewAdminuserLogic(ctx *gin.Context, svcCtx *svc.ServiceContext) *adminuserLogic {
	return &adminuserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

/**
 * @description(数据列表)
 * @buildcode(true)
*/
func (p adminuserLogic) GetPageList(req *dto.AdminuserPageReq) ([]*vo.AdminuserList, int64, error) {
	s := service.NewAdminuserService(p.svcCtx)
	return s.GetPageList(req)
}

/**
 * @description(修改排序开关)
 * @buildcode(true)
*/
func (p adminuserLogic) UpdateExt(req map[string]interface{}) error {
	s := service.NewAdminuserService(p.svcCtx)
	return s.UpdateExt(req)
}

/**
 * @description(添加)
 * @buildcode(true)
*/
func (p adminuserLogic) Add(req *dto.AdminuserAddReq) (int, error) {
	s := service.NewAdminuserService(p.svcCtx)
	return s.Add(req)
}

/**
 * @description(修改)
 * @buildcode(true)
*/
func (p adminuserLogic) Update(req *dto.AdminuserUpdateReq) error {
	s := service.NewAdminuserService(p.svcCtx)
	return s.Update(req)
}

/**
 * @description(获取修改详情)
 * @buildcode(true)
*/
func (p adminuserLogic) GetUpdateInfo(req *dto.AdminuserGetUpdateInfoReq) (*model.Adminuser, error) {
	s := service.NewAdminuserService(p.svcCtx)
	return s.GetUpdateInfo(req)
}

/**
 * @description(删除)
 * @buildcode(true)
*/
func (p adminuserLogic) Delete(req *dto.AdminuserDeleteReq) error {
	s := service.NewAdminuserService(p.svcCtx)
	return s.Delete(req)
}

/**
 * @description(查看详情)
 * @buildcode(true)
*/
func (p adminuserLogic) Detail(req *dto.AdminuserDetailReq) (*vo.AdminuserDetail, error) {
	s := service.NewAdminuserService(p.svcCtx)
	return s.Detail(req)
}

/**
 * @description(重置密码)
 * @buildcode(true)
*/
func (p adminuserLogic) ResetPwd(req *dto.AdminuserResetPwdReq) error {
	s := service.NewAdminuserService(p.svcCtx)
	return s.ResetPwd(req)
}

/**
 * @description(查询sql下拉字段列表)
 * @buildcode(true)
*/
func (p adminuserLogic) GetFieldList(c *gin.Context) (map[string]interface{}, error) {
	s := service.NewAdminuserService(p.svcCtx)
	return s.GetFieldList(p.ctx)
}

